Skip to content

fix(dashboard): handle missing RealUnit price instead of crashing the price chart#695

Merged
TaprootFreak merged 1 commit into
stagingfrom
feature/price-chart-skip-null-values
Jun 5, 2026
Merged

fix(dashboard): handle missing RealUnit price instead of crashing the price chart#695
TaprootFreak merged 1 commit into
stagingfrom
feature/price-chart-skip-null-values

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Problem

The public price view ("RealUnit Aktienkurs") shows an empty chart and CHF --.-- whenever the RealUnit quote is temporarily unavailable.

Confirmed against the live API:

  • GET /v1/realunit/price{"timestamp":"2026-06-04T22:28:16.539Z"}no chf/eur.
  • GET /v1/realunit/price/history?timeFrame=ALL1514 points, 1513 valid, only the latest (2026-06-04) has no chf/eur.

DFXPriceService.getPriceChart did BigInt.from(entry['chf'] * 100) for every entry, so the single null point threw (null * 100), the whole method threw, and priceChart stayed [] → the entire history (1513 valid points) was discarded and the chart rendered empty. getPriceOfAsset threw on the same null.

This is the same defect class as the portfolio-chart fix in #694, but in the price code path (dfx_price_service.dart), which #694 does not touch. It is more visible because it affects the wallet-less public price view.

Fix

  • getPriceChart: skip entries whose selected-currency price is null instead of throwing — the chart renders the full history minus the unpriced tail point.
  • getPriceOfAsset: return BigInt.zero when the price is missing, so the UI renders --.-- instead of throwing.
  • getChfToEurRate: treat a missing chf/eur as 0 (already guards chf > 0).

Tests

  • getPriceChart skips a trailing null point and keeps earlier valued points.
  • getPriceOfAsset returns zero on a missing price.
  • getChfToEurRate returns 0.0 on a missing price.
  • flutter analyze clean; price-service + price-chart-cubit suites green (22 tests).

Test plan

  • Open the app with no wallet while the quote endpoint omits chf/eur → price chart renders full history, header --.--, no empty chart.
  • Normal case (all prices present) → unchanged.
  • Current price endpoint without chf/eur → header --.--, no crash.

Related

… chart

The price endpoints omit chf/eur while a quote is unavailable: /v1/realunit/price
returns just a timestamp, and the latest entry of /v1/realunit/price/history has
no chf/eur. getPriceChart did BigInt.from(entry['chf'] * 100) per entry, so a
single null point threw and discarded the ENTIRE price history, leaving the
chart empty. getPriceOfAsset threw on the same null.

- getPriceChart: skip entries whose selected-currency price is null, keeping all
  valued points (chart renders the full history minus the unpriced tail).
- getPriceOfAsset: return zero when the price is missing so the UI shows "--.--".
- getChfToEurRate: treat a missing chf/eur as 0 (no throw, already guards chf>0).
@TaprootFreak TaprootFreak marked this pull request as ready for review June 5, 2026 06:37
@TaprootFreak TaprootFreak merged commit 8a2e056 into staging Jun 5, 2026
10 checks passed
@TaprootFreak TaprootFreak deleted the feature/price-chart-skip-null-values branch June 5, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant